package com.gzm.check.utils;

import lombok.Getter;

import java.util.Arrays;

/**
 * 体检数据对应的枚举类(尿常规)
 * 首个参数放的是对应的代码值,
 * 使用数组是因为,不同设备上传上来的代码值有可能是不同的例如
 * A设置上传上来的白细胞数代码为A B设备上传的代码值为B ,虽然代码值不同但是对应的值应该是相同的,方便扩展
 * 下列参数均为对象字段名称,用反射获取字段,为之赋值和获取值
 * 第二个参数名为血常规中对应字段的字段名称
 * 第三个字段为对象结果单位
 * 第四个对象为参考值上限
 * 第五个对象为参考值下限
 */
@Getter
public enum UrineRoutEnum {

    //LEU	白细胞
    LEU(new String[]{"LEU"}, "leu", "leuUnit", "leuUpper", "leuLower"),
    //NIT	亚硝酸盐
    NIT(new String[]{"LEU"}, "nit", "nitUnit", "nitUpper", "nitLower"),
    //URO	尿胆原
    URO(new String[]{"URO"}, "uro", "uroUnit", "uroUpper", "uroLower"),
    //PRO	蛋白
    PRO(new String[]{"PRO"}, "pro", "proUnit", "proUpper", "proLower"),
    //PH	PH
    PH(new String[]{"PH"}, "ph", "phUnit", "phUpper", "phLower"),
    //BLD	潜血
    BLD(new String[]{"BLD"}, "bld", "bldUnit", "bldUpper", "bldLower"),
    //SG	比重
    SG(new String[]{"SG"}, "sg", "sgUnit", "sgUpper", "sgLower"),
    //KET	酮体
    KET(new String[]{"KET"}, "ket", "ketUnit", "ketUpper", "ketLower"),
    //BIL	胆红素
    BIL(new String[]{"BIL"}, "bil", "bilUnit", "bilUpper", "bilLower"),
    //GLU	葡萄糖
    GLU(new String[]{"GLU"}, "glu", "gluUnit", "gluUpper", "gluLower"),
    //VC	维生素C
    VC(new String[]{"VC"}, "vc", "vcUnit", "vcUpper", "vcLower");


    private String[] code;
    private String fieldName;
    private String fieldNameUnit;
    private String upper;
    private String lower;


    UrineRoutEnum(String[] code, String fieldName, String fieldNameUnit, String upper, String lower) {
        this.code = code;
        this.fieldName = fieldName;
        this.fieldNameUnit = fieldNameUnit;
        this.upper = upper;
        this.lower = lower;
    }

    public static String getFieldName(String code) {
        for (UrineRoutEnum c : UrineRoutEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.fieldName;
            }
        }
        return null;
    }

    public static String getFieldNameUnit(String code) {
        for (UrineRoutEnum c : UrineRoutEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.fieldNameUnit;
            }
        }
        return null;
    }

    public static String getLower(String code) {
        for (UrineRoutEnum c : UrineRoutEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.lower;
            }
        }
        return null;
    }

    public static String getUpper(String code) {
        for (UrineRoutEnum c : UrineRoutEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.upper;
            }
        }
        return null;
    }

}
